<template>
  <div id="app">
 

    <el-container>
      <el-main>
        <el-card>
          <div class="filter-options">
            <el-row :gutter="20">
              <el-col :span="6">
                <div style="width: 800px">
                  <span>价格区间:</span>
                  <el-radio-group v-model="filters.skuIntegral">
                    <el-radio-button label="全部"></el-radio-button>
                    <el-radio-button label="300以下"></el-radio-button>
                    <el-radio-button label="300-699"></el-radio-button>
                    <el-radio-button label="700-999"></el-radio-button>
                    <el-radio-button label="1000-1999"></el-radio-button>
                    <el-radio-button label="2000-2999"></el-radio-button>
                    <el-radio-button label="3000以上"></el-radio-button>
                  </el-radio-group>
                </div>
              </el-col>
              <!-- 其他的 el-col 组件 -->
            </el-row>
          </div>
        </el-card>
        <el-card>
          <el-row :gutter="20">
            <el-col
              :span="6"
              v-for="product in filteredProducts"
              :key="product.id"
            >
              <el-card :body-style="{ padding: '20px' }">
                <div style="padding: 14px">
                  <span>{{ product.spuName }}</span>
                  <div class="bottom clearfix">
                    <span class="skuIntegral"
                      >{{ product.skuIntegral }}积分</span
                    >
                    <el-button
                      type="primary"
                      size="mini"
                      @click="queryDetail(product.id)"
                      >查看详情</el-button
                    >
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-card>
      </el-main>
    </el-container>


  </div>
</template>
  
<script>
export default {
  data() {
    return {
      filters: {
        skuIntegral:"全部"
      },
      products: [],
      activeTab: "popular",
 


    };
  },
  methods: {
    querySkus() {
      this.$axios.post("/api/zgyd-jifen/querySpus").then((res) => {
        if (res.data.code === 200) {
          this.products = res.data.data;
        }
      });
    },
    queryDetail(val) {
      this.$router.push({ path: "/skuDetail", query: { spuId: val } });
    },

  },
  computed: {
    filteredProducts() {
      // 根据 filters 进行筛选并返回筛选后的商品列表
      return this.products.filter((product) => {
        // 根据价格筛选
        const skuIntegralMatch =
          this.filters.skuIntegral === "全部" ||
          (this.filters.skuIntegral < "300以下" &&
            product.skuIntegral >= 0 &&
            product.skuIntegral <= 299) ||
          (this.filters.skuIntegral === "300-699" &&
            product.skuIntegral >= 300 &&
            product.skuIntegral <= 699) ||
          (this.filters.skuIntegral === "700-999" &&
            product.skuIntegral >= 700 &&
            product.skuIntegral <= 999) ||
          (this.filters.skuIntegral === "1000-1999" &&
            product.skuIntegral >= 1000 &&
            product.skuIntegral <= 1999) ||
          (this.filters.skuIntegral === "2000-2999" &&
            product.skuIntegral >= 2000 &&
            product.skuIntegral <= 2999) ||
          (this.filters.skuIntegral === "3000以上" &&
            product.skuIntegral >= 3000);

        // 根据其他条件筛选（略）
        return skuIntegralMatch;
      });
    },
  },
  created() {
    this.querySkus();
  },
};
</script>
  
<style>
.banner .el-carousel img {
  width: 100%;
  height: 100%;
}
.header nav ul {
  list-style-type: none;
  display: flex;
  margin: 0;
  padding: 0;
}
.header nav li {
  margin: 0 10px;
}
.header nav a {
  text-decoration: none;
  color: #333;
  font-weight: bold;
}
.main-content {
  padding: 20px;
}
.banner img {
  width: auto;
  height: auto;
}
.icon-nav {
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
}
.icon-nav ul {
  list-style-type: none;
  display: flex;
  margin: 0;
  padding: 0;
}
.icon-nav li {
  text-align: center;
  margin: 0 15px;
}
.icon-nav a {
  text-decoration: none;
  color: #333;
}
.icon-nav i {
  display: block;
  font-size: 24px;
  margin-bottom: 5px;
}
.sections {
  margin-top: 20px;
}
.section {
  margin-bottom: 40px;
}
.section h2 {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
}
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.tabs button {
  padding: 10px 20px;
  border: none;
  cursor: pointer;
}
.cards {
  display: flex;
  gap: 20px;
}
.card {
  flex: 1;
  background-color: #fff;
  padding: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  text-align: center;
}
.card h3 {
  margin: 10px 0;
}
.card p {
  color: #666;
}
.footer {
  text-align: center;
  padding: 20px 0;
  background-color: #f5f5f5;
}
</style>
  